home *** CD-ROM | disk | FTP | other *** search
/ Info-Mac 4 / Info_Mac IV CD-ROM (Pacific HiTech Inc.)(August 1994).iso / Communications / General / LineShare Folder / Put Onto Productions Disks / LineShare Scripts / Generic Fax2&ARA&Data < prev    next >
Text File  |  1994-03-23  |  7KB  |  326 lines

  1. ! Version 2.1
  2. !
  3. !$ Requires: Class 2 fax modem, hardware handshaking cable.
  4.  
  5. !$ Supports: fax, ARA, and a generic comm. software in the server mode.
  6.  
  7. !$ Use:   Class 2 for Fax, ARA/LineShare for ARA.
  8.  
  9. !$ Read:  your modem manual to modify the "AT" strings.
  10.  
  11. !$ See:   the Generic Scripts Guide for details.
  12.  
  13. ^2 Speaker On:        = Enum("Never" = "0" ,  "When Connecting" = "1", "Always"="2") "1"
  14. ^3 Speaker Volume:    = Enum("Low"="1","Medium"="2","High"="3") "2"
  15. ^4 Answer On:         = Enum("1 Ring"="1","2 Rings"="2","3 Rings"="3","5 Rings"="5","7 Rings"="7") "2"
  16. ^5 Fax Identifier:    = Text "Stalker_GmbH"
  17. ^6 AT for Receive:      = Text ""
  18. ^7 AT for HW Handshake: = Text ""
  19. ^8 AT for SW Handshake: = Text ""
  20. ^9 AT for Normal mode:  = Text ""
  21.  
  22. ! ------------------------------------------
  23. ! Resetting the modem:
  24. ! ------------------------------------------
  25. @Hangup
  26.   SerReset 19200,0,8,1
  27.   SetTries 2
  28.   Flush
  29.   HsReset 0,0,17,19,0,0
  30. !
  31. ! Try to catch the "OK" answer, use the Escape seq and DTR transitions
  32. ! to enter the command mode
  33. !
  34. @Label 1
  35.   matchclr
  36.   matchstr 1 2 "OK\r\n"
  37.   write "ATH0&F\r"
  38.   matchread 20
  39.   Write "+++"
  40.   DtrClear
  41.   pause 10
  42.   DtrSet
  43. !
  44.   DecTries
  45.   IfTries 0 1
  46. !
  47. ! OSErr -6019 "Modem error - the modem is not responding"
  48. !
  49.   exit -6019
  50. @Label 2
  51.   write "AT+FCLASS=0\r"
  52.   Jsr 100
  53.   write "AT+FAA=0\r"
  54.   Jsr 100
  55.   exit 0
  56. ! ------------------------------------------
  57. !    Receiving incoming calls
  58. ! ------------------------------------------
  59. @ANSWER
  60.   SetVar A ""
  61.   IfStr A 50 "^6^7^8^9"
  62. @Label 10
  63.   SerReset 19200,0,8,1
  64.   Jsr 80
  65. !
  66. ! Set the common options
  67.   Jsr 70
  68. !
  69. ! Set the communication options:
  70. ! • ^6 for receive mode (disable MNP), <DCE Speed>/ARQ message
  71. ! • ^7 HW flow control
  72. !!
  73.   Write "AT^7^6\r"
  74.   Jsr 100
  75. !
  76. ! Set Fax parameters: LID, DCC,BOR
  77. !
  78.   Write "AT+FCLASS=2\r"
  79.   Jsr 100
  80.   Write "AT+FLID=\"^5\"\r"
  81.   Jsr 100
  82.   Write "AT+FDCC=1,3,0,2,0,0,0,0\r"
  83.   Jsr 100
  84.   Write "AT+FBOR=1\r"
  85.   Jsr 100
  86. !
  87. ! Allow modem to receive fax messages
  88. !
  89.   Write "AT+FCR=1\r"
  90.   Jsr 100
  91. !
  92. ! Tell the modem to determine the type of the incoming call
  93. ! Fetch the tube after ^4 rings
  94. !
  95.   Write "ATS0=^4+FAA=1\r"
  96.   Jsr 100
  97.   Note "Waiting for Fax/ARA/Data calls…"
  98. !
  99. ! Everything is ready - let's sit and wait for a call
  100. ! We'll wait for 2 minutes, then reinitiate the modem
  101. !
  102. @Label 12
  103.   MatchClr
  104.   matchstr 1 13 "RING\r\n"
  105.   matchstr 2 21 "\r\nCONNECT ^$/ARQ"
  106.   matchstr 3 15 "\r\nCONNECT ^$\r\n"
  107.   matchstr 9 40 "\r\n+FCON"
  108.   matchstr 10 10 "\r\nNO "
  109.   matchstr 11 10 "\r\nBUSY"
  110.   Matchread 1200
  111.   Jump 10
  112. @Label 13
  113.   Note "Ring…"
  114.   Jump 12
  115. !
  116. ! Data connection has been established (we read "CONNECT XXX\r\n")
  117. ! Put the "CONNECT" back to the buffer and attach the "Data" subPort
  118. ! if it was an incoming call, put the "RING" before the "CONNECT"
  119. !
  120. @Label 15
  121.   SetVar A "^$"
  122.   Note "Non-V.42 Call at ^A bps. Waiting for an ARA frame."
  123.   MatchClr
  124.   MatchStr 1 20 "\r"
  125.   MatchStr 2 30 "\08\01\03\14\04\03\00\08\250\16\03"
  126.   MatchRead 40
  127.  
  128. @Label 20
  129.   Note "Non-ARA call"
  130.   Flush
  131.   Jump 24
  132. !
  133. ! V.42 call detected
  134. !
  135. @Label 21
  136.   SetVar A "^$"
  137.   Note "V.42 Call at ^A bps"
  138.   MatchClr
  139.   MatchStr 1 24 "\r\n"
  140.   MatchRead 5
  141. @Label 24
  142.   QueueInput "\r\nRING\r\n\r\nCONNECT ^A\r\n"
  143. @Label 25
  144.   Attach "Data" (DTR,Escape,TimeLimit=0)
  145.  
  146. !
  147. ! The ARA (MNP 4) frame detected
  148. !
  149. @Label 30
  150.   Note "ARA call at ^A bps."
  151.   Flush
  152.   QueueInput "\r\nRING\r\n\r\nCARRIER ^A\r\n"
  153. @Label 32
  154.   Attach "ARA" (DTR,Escape,TimeLimit=0)
  155.  
  156. !
  157. ! Fax connection has been established (we read "+FCON")
  158. ! Put the +FCON back to the buffer,
  159. ! if it was an incoming call, put the "RING" before the "+FCON"
  160. ! Attach the "Fax" subPort
  161. !
  162. @Label 40
  163.   QueueInput "\r\n+FCON"
  164.   ifOriginate 41
  165.   QueueInput "\r\nRING\r\n"
  166. @Label 41
  167.   Attach "Fax" (DTR,Reset,Escape,IdleLimit=30)
  168.  
  169. ! ------------------------------------------
  170. ! Originating a call through the "ARA" subport
  171. ! ------------------------------------------
  172. @ORIGINATE "ARA"
  173.   SerReset 19200,0,8,1
  174.   Jsr 80
  175. !
  176. ! Set the common options
  177. !
  178.   Jsr 70
  179. !
  180. ! Set the Data mode:
  181. ! • ^9 Normal connection, DCE speed
  182. ! • ^7  Hardware handshake
  183. ! • S7:  time-out (90 sec) for long-distance call (if you use them)
  184. !
  185.   Write "AT^7^9\r"
  186.   Jsr 100
  187. !
  188. ! Prepare to receive all error result codes
  189. !
  190.   Jsr 90
  191.   MatchStr 1 45 "\r\nCONNECT "
  192.   MatchRead 900
  193.   Write "\r"
  194.   Exit -6019
  195.  
  196. @Label 45
  197.   QueueInput "\r\nCARRIER "
  198.   Jump 32
  199.  
  200. ! ------------------------------------------
  201. ! Originating a call through the "Data" subport
  202. ! ------------------------------------------
  203. @ORIGINATE "Data"
  204.   SerReset 19200,0,8,1
  205.   Jsr 80
  206.   Jsr 70
  207. !
  208. ! Now emit all commands that the application has sent to that port
  209. !
  210.   Jsr 60
  211.   SerReset *
  212.   Jsr 80
  213. !
  214. ! Prepare to receive all error result codes
  215. !
  216.   Flush
  217.   Jsr 90
  218.   MatchStr 1 48 "^$\r\nCONNECT"
  219.   MatchRead 900
  220.   Write "\r"
  221.   Exit -6019
  222. @Label 48
  223.   QueueInput "^$\r\nCONNECT"
  224.   Jump 25
  225.  
  226. ! ------------------------------------------
  227. ! Originating a call through the "Fax" subPort
  228. ! ------------------------------------------
  229. @ORIGINATE "Fax" ("\r\nLineShare Line is Busy\r\nBUSY\r\n")
  230.   SerReset 19200,0,8,1
  231.   Jsr 80
  232. !
  233. ! Set the common options
  234. !
  235.   Jsr 70
  236. !
  237. ! Set the Fax mode
  238. !
  239.   Write "AT^8+FCLASS=2\r"
  240.   Jsr 100
  241. !
  242. ! Now emit all commands that the application has sent to that port,
  243. ! Prepare to receive all error result codes
  244. !
  245.   Jsr 60
  246.   Jsr 90
  247.   MatchStr 1 40 "\r\n+FCON"
  248.   MatchRead 700
  249.   Write "\r"
  250.   Exit -6019
  251.  
  252. @Label 50
  253.   Note "Suspended"
  254.   Say "Press the Option button to enter the AT-strings for your modem!"
  255.   Pause 1200
  256.   Jump 50
  257.  
  258. !
  259. ! This section emits all modem commands sent from the client application
  260. ! For each set of commands the "OK" answer is awaited
  261. !
  262. @Label 60
  263.   EmitStart
  264. @Label 61
  265.   EmitCommand 62
  266.   Jsr 100
  267.   Jump 61
  268. @Label 62
  269.   return
  270. !
  271. ! This section initiates the modem before ANSWER and ORIGINATEs:
  272. ! dialtone detect + connect at the highest rate + speaker control +
  273. ! hang up on Dtr drop + DCD valid
  274. ! Verbal responses mode, no echo
  275. ! Disable extended codes
  276. !
  277. @Label 70
  278.   Write "ATX4M^2L^3&D2&C1V1E0\r"
  279.   Jsr 100
  280.   return 
  281. !
  282. ! This section syncronize the modem after the serial port speed switching
  283. !
  284. @Label 80
  285.   ChrDelay 1
  286.   Write "AT\r"
  287.   ChrDelay 0
  288.   Jsr 100
  289.   return
  290. !
  291. ! Prepare to receive error result codes
  292. !
  293. @Label 90
  294.   MatchClr
  295.   MatchStr 2 91 "NO DIALTONE\r\n"
  296.   MatchStr 3 92 "BUSY\r\n"
  297.   MatchStr 4 93 "NO CARRIER\r\n"
  298.   MatchStr 5 94 "NO ANSWER\r\n"
  299.   Write "ATD^1\r"
  300.   HsReset *
  301.   return
  302.  
  303. @Label 91
  304.   exit -6020
  305. @Label 92
  306.   exit -6022
  307. @Label 93
  308.   exit -6021
  309. @Label 94
  310.   exit -6023
  311. !
  312. ! Processing the AT command:
  313. ! OK -> proceed
  314. ! ERROR or TimeOut ->exit -6019
  315. ! It can be called AFTER the "Write" command, since LineShare buffers input
  316. !
  317. @Label 100
  318.   MatchClr
  319.   MatchStr 1 102 "\r\nOK\r\n"
  320.   MatchStr 2 101 "\r\nERROR\r\n"
  321.   MatchRead 20
  322. @Label 101
  323.   Exit -6019
  324. @Label 102
  325.   return
  326.